using System;
using System.Collections.Generic;
using Top.Api.Response;
using Top.Api.Util;

namespace Top.Api.Request
{
    /// <summary>
    /// TOP API: taobao.marketing.promotion.update
    /// </summary>
    public class MarketingPromotionUpdateRequest : ITopRequest<MarketingPromotionUpdateResponse>
    {
        /// <summary>
        /// 减价件数。只有discount_type=PRICE有效，1只减一件，0表示多件，不为1的其他数字都作0处理；discount_type=DISCOUNT该参数无效。
        /// </summary>
        public Nullable<long> DecreaseNum { get; set; }

        /// <summary>
        /// 折扣类型，可选PRICE(优惠价格)和DISCOUNT(折扣)，填写其它值返回错误
        /// </summary>
        public string DiscountType { get; set; }

        /// <summary>
        /// 优惠额度，若优惠类型为折扣（DISCOUNT），则传入该商品的折扣比例，有效值范围：0.01-9.99，支持小数点后2位。若优惠类型为优惠价格(PRICE)，传入该商品的优惠价，单位：元，支持小数点后2位
        /// </summary>
        public string DiscountValue { get; set; }

        /// <summary>
        /// 优惠结束时间
        /// </summary>
        public Nullable<DateTime> EndDate { get; set; }

        /// <summary>
        /// 活动描述，最多30个字符
        /// </summary>
        public string PromotionDesc { get; set; }

        /// <summary>
        /// 优惠ID
        /// </summary>
        public Nullable<long> PromotionId { get; set; }

        /// <summary>
        /// 活动名称，最多5个字符
        /// </summary>
        public string PromotionTitle { get; set; }

        /// <summary>
        /// 优惠开始时间
        /// </summary>
        public Nullable<DateTime> StartDate { get; set; }

        /// <summary>
        /// 标签ID
        /// </summary>
        public Nullable<long> TagId { get; set; }

        #region ITopRequest Members

        public string GetApiName()
        {
            return "taobao.marketing.promotion.update";
        }

        public IDictionary<string, string> GetParameters()
        {
            TopDictionary parameters = new TopDictionary();
            parameters.Add("decrease_num", this.DecreaseNum);
            parameters.Add("discount_type", this.DiscountType);
            parameters.Add("discount_value", this.DiscountValue);
            parameters.Add("end_date", this.EndDate);
            parameters.Add("promotion_desc", this.PromotionDesc);
            parameters.Add("promotion_id", this.PromotionId);
            parameters.Add("promotion_title", this.PromotionTitle);
            parameters.Add("start_date", this.StartDate);
            parameters.Add("tag_id", this.TagId);
            return parameters;
        }

        public void Validate()
        {
            RequestValidator.ValidateRequired("discount_type", this.DiscountType);
            RequestValidator.ValidateRequired("discount_value", this.DiscountValue);
            RequestValidator.ValidateRequired("end_date", this.EndDate);
            RequestValidator.ValidateRequired("promotion_id", this.PromotionId);
            RequestValidator.ValidateRequired("start_date", this.StartDate);
            RequestValidator.ValidateRequired("tag_id", this.TagId);
        }

        #endregion
    }
}
